#ifndef SOBJ_H
#define SOBJ_H

#include <iostream>
#include <fstream>
#include <cmath>
#include <complex>
#include <string.h>

#define PI 3.14159265
#define FFT_WIDTH 2000

using namespace std;

class SoundObj
{
	private:

		long SampleSize;
		long ChannelSize;

		char* FileTypeBlockID;
		long FileSize;
		char* FileFormatID;

		char* FormatBlockID;
		long BlockSize;
		long AudioFormat;
		long NbrOfChannels;
		long Frequency;
		long BytePerSec;
		long BytePerBlock;
		long BitsPerSample;

		char* DataBlockID;
		long DataSize;

	public:

		long** DATA;
		double *Equalizer;
		complex<double>** FFt;
		SoundObj(bool);
		SoundObj(const char* FILE);
		SoundObj(long = 0,long = 100,long = 60,long = 30000,long = 44100);
		void Read(const char* FILE);
		void Write(const char* FILE);
		long BinToDecimal(ifstream& file,const long dataSize) const;
		void DecimalToBin(ofstream& file, const long dataSize, long value) const;
		long setSampleSize(long newSampleSize);
		~SoundObj();

		long** getData();
		long*  getDataByChannel(long channel);
		long   getDataByBits(long channel, long bit);
		long   getDataSize();
		long   getSoundLength();
		long   getNbrOfChannels();
		long   getBytePerSec();
		double* getEqualizer();
		long   getAudioFormat();

		void InitEqualizer();
		complex<double>* Equalize(complex<double> *fft);
		void updateEqualizer(long id, long val);
		SoundObj * Concat(SoundObj *);
		long mixWith(SoundObj*,long mod=1);
		complex<double>* computeFFT(long channel);
		complex<double>* FFT(const complex<double>* data, const long n);
		complex<double>* computeIFFT(long channel);
		complex<double>* IFFT(const complex<double>* data, const long n);
		complex<double> Sum(const complex<double>* data, const long n, const long k, const long even);
};

#endif
